package demo8;

public class Triple_Step {

    /**
     * f3=f2+f1
     * f2=f1+f1
     * f1=1
     * how to plus to  n stage,
     *
     */
    public int  goUpToStageWithInitAndStart(int n){
        return goUpToStage(n,new int[n+1]);
    }
    public int  goUpToStage(int n,int[] memo){
        if(n==1) return 1;
        if(n==2) return 2;
        if(n==3) return 3;
        if(memo[n]==0){
            memo[n]=goUpToStage(n-1,memo) + goUpToStage(n-2,memo)+goUpToStage(n-3,memo);
        }
        return memo[n];
    }
}
